module.exports = (app) => {
  const { STRING, INTEGER, DATE, NOW } = app.Sequelize

  const DictItem = app.model.define(
    'sys_dict_item',
    {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
        comment: '字典项主键'
      },
      pid: {
        type: INTEGER,
        comment: '字典父项ID'
      },
      dict_code: {
        type: STRING,
        allowNull: false,
        defaultValue: '',
        comment: '字典外键'
      },
      item_name: {
        type: STRING,
        comment: '字典项名'
      },
      item_desc: {
        type: STRING,
        comment: '字典项描述'
      },
      item_icon: {
        type: STRING,
        comment: '字典项图标'
      },
      state: {
        type: INTEGER,
        allowNull: false,
        defaultValue: 1,
        comment: '状态 0:禁用 1:启用'
      },
      rank: {
        type: INTEGER,
        allowNull: false,
        defaultValue: 1,
        comment: '排序 越大越靠前'
      },
      created_at: {
        type: DATE,
        allowNull: false,
        defaultValue: NOW,
        comment: '创建时间'
      },
      updated_at: {
        type: DATE,
        allowNull: false,
        defaultValue: NOW,
        comment: '更新时间'
      }
    },
    {
      freezeTableName: true, // Model 对应的表名将与model名相同
      timestamps: false
    }
  )
  return DictItem
}
